package demo1;

public class Computer {
    public void openComputer() {
        System.out.println("打开电脑");
    }
    //判断使用鼠标还是键盘
    public void useDevice(IUSB iusb) {
        iusb.openDevice();
        if(iusb instanceof Mouse) {
            Mouse mouse = (Mouse) iusb;//向下转型
            mouse.usMouse();
        }else if(iusb instanceof KeyBoard) {
            KeyBoard keyBoard = (KeyBoard)iusb;
            keyBoard.usKeyBoard();
        }else {
            System.out.println("不属于任何一种输入设备");
        }

        iusb.closeDevice();
    }
    public void powerComputer() {
        System.out.println("关闭电脑");
    }
}
